package com.yxq.mdt.app.modules.spike.ui;

import android.graphics.Paint;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.glide.GlideHelper;
import com.yxq.mdt.app.modules.spike.bean.SpikeGoodsBean;

import java.util.List;

/**
 * @author L
 * @time 2019-11-06
 * @describe 秒杀商品列表$
 */
public class SpikeGoodsListAdapter extends BaseQuickAdapter<SpikeGoodsBean.ListBean, BaseViewHolder> {
    public SpikeGoodsListAdapter(int layoutResId, @Nullable List<SpikeGoodsBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SpikeGoodsBean.ListBean item) {
        GlideHelper.setLoadRoundImage(mContext, item.getCover_pic(), 0, helper.getView(R.id.cart_iv_img));
        helper.setText(R.id.cart_tv_name, item.getName());
        TextView priceView = helper.getView(R.id.cart_tv_price_old);
        priceView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        helper.setText(R.id.cart_tv_price, String.format("￥%.2f", item.getMiaosha_price()));
        helper.setText(R.id.cart_tv_price_old, String.format("￥%.2f", item.getPrice()));
    }
}
